package cn.iocoder.yudao.module.xiaoBizHandler.dal.mysql.tbFolder;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.xiaoBizHandler.dal.dataobject.tbFolder.XTbFolderDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.xiaoBizHandler.controller.admin.tbFolder.vo.*;

/**
 * 文件夹 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface XTbFolderMapper extends BaseMapperX<XTbFolderDO> {

    default PageResult<XTbFolderDO> selectPage(XTbFolderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<XTbFolderDO>()
                .likeIfPresent(XTbFolderDO::getName, reqVO.getName())
                .eqIfPresent(XTbFolderDO::getParentId, reqVO.getParentId())
                .eqIfPresent(XTbFolderDO::getSort, reqVO.getSort())
                .eqIfPresent(XTbFolderDO::getOwnerUserId, reqVO.getOwnerUserId())
                .eqIfPresent(XTbFolderDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(XTbFolderDO::getFolderCreateTime, reqVO.getBeginFolderCreateTime(), reqVO.getEndFolderCreateTime())
                .betweenIfPresent(XTbFolderDO::getFolderLastTime, reqVO.getBeginFolderLastTime(), reqVO.getEndFolderLastTime())
                .betweenIfPresent(XTbFolderDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(XTbFolderDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(XTbFolderDO::getId));
    }

    default List<XTbFolderDO> selectList(XTbFolderExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<XTbFolderDO>()
                .likeIfPresent(XTbFolderDO::getName, reqVO.getName())
                .eqIfPresent(XTbFolderDO::getParentId, reqVO.getParentId())
                .eqIfPresent(XTbFolderDO::getSort, reqVO.getSort())
                .eqIfPresent(XTbFolderDO::getOwnerUserId, reqVO.getOwnerUserId())
                .eqIfPresent(XTbFolderDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(XTbFolderDO::getFolderCreateTime, reqVO.getBeginFolderCreateTime(), reqVO.getEndFolderCreateTime())
                .betweenIfPresent(XTbFolderDO::getFolderLastTime, reqVO.getBeginFolderLastTime(), reqVO.getEndFolderLastTime())
                .betweenIfPresent(XTbFolderDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(XTbFolderDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(XTbFolderDO::getId));
    }

    default List<XTbFolderDO> selectList(XTbFolderListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<XTbFolderDO>()
                .likeIfPresent(XTbFolderDO::getName, reqVO.getName())
                .eqIfPresent(XTbFolderDO::getStatus, reqVO.getStatus())
        );
    }

}
